# -*- coding : utf_8 -*-
"""
=======================================
Time : 2025/4/14 23:38
Author : 田霄汉
Email : 522989570@qq.com
File : combat_class25.py
Project : pandas_demo
Function : 插入、修改、新增、删除数据列
=======================================
"""
import pandas as pd
from pandas import DataFrame
from config.setting import file_path
import numpy as np

combat25_path = file_path['excel_path'] + '/combat25.xlsx'

pd.options.display.max_columns = 999
page01: DataFrame = pd.read_excel(io=combat25_path,
                                  sheet_name='page1',
                                  skiprows=3,
                                  usecols='C:E')
page02: DataFrame = pd.read_excel(io=combat25_path,
                                  sheet_name='page2',
                                  skiprows=3,
                                  usecols='C:E')
# pandas.concat()也可以实现两个DataFrame的拼接,而且可以实现纵向和横向拼接.
students: DataFrame = pd.concat(objs=[page01, page02], axis=0).reset_index(drop=True)
# 最后追加列'Class'
students['Class'] = '五年(5)班'
# 中间插入列'Age'
students.insert(loc=1, column='Age', value=np.repeat(25, len(students)))
# 删除列'Test01','Age'
students.drop(columns=['id', 'Age'], inplace=True)
# 修改列名
students.rename(columns={'Full Name': 'Name', 'Test01': 'Score'}, inplace=True)

print(students)
